package sdufe.lele.dao;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.InsertProvider;
import org.springframework.stereotype.Repository;
import sdufe.lele.model.Userinfo;
import sdufe.lele.mybatisProvider.CreateProvider;
import sdufe.lele.mybatisProvider.UpdatesProvider;

import java.math.BigDecimal;
import java.util.List;

@Repository
@Mapper
public interface UserinfoMapper {


    @Delete("delete from userinfo where userId = #{userid}")
    int deleteByPrimaryKey(@Param("userid") Integer userid);

    @Select("SELECT * FROM userinfo WHERE userTele = #{phone}")
    Userinfo selectByPhone(@Param("phone") String phoneNum);

    @Select("SELECT * FROM userinfo WHERE userEmail = #{email}")
    Userinfo selectByEmail(@Param("email") String email);

    @Select("select * from userinfo where userId = #{userid}")
    Userinfo selectByPrimaryKey(@Param("userid") Integer userid);

    @Select("select * from userinfo where userLevel = 1")
    List<Userinfo> selectNormal();


    @UpdateProvider(type = UpdatesProvider.class,method = "userInfoUpdateById")
    int updateByPrimaryKeySelective(Userinfo record);

    @UpdateProvider(type = UpdatesProvider.class,method = "userInfoUpdateByName")
    int updateByName(Userinfo record);

    @InsertProvider(type = CreateProvider.class,method = "userInfoInsertSelective")
    int insertSelective(Userinfo record);

    @Update("update  userinfo set balance = #{balance} where userTele = #{phone}")
    int updateBalance(@Param("balance")BigDecimal balance , @Param("phone")String phone);





}